package com.ruoyi.gams.controller;

import java.util.List;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.gams.domain.GamsAppVersion;
import com.ruoyi.gams.service.IGamsAppVersionService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 政务APP版本管理Controller
 *
 * @author ruoyi
 */
@Api(tags = "广告系统后台：政务APP版本管理")
@RestController
@RequestMapping("/gams/version")
public class GamsAppVersionController extends BaseController
{
    @Autowired
    private IGamsAppVersionService gamsAppVersionService;

    /**
     * 查询政务APP版本管理列表
     */
    @ApiOperation("查询政务APP版本管理列表")
    @PreAuthorize("@ss.hasPermi('gams:version:list')")
    @GetMapping("/list")
    public TableDataInfo list(GamsAppVersion gamsAppVersion)
    {
        startPage();
        List<GamsAppVersion> list = gamsAppVersionService.selectGamsAppVersionList(gamsAppVersion);
        return getDataTable(list);
    }

    /**
     * 导出政务APP版本管理列表
     */
    @ApiOperation("导出政务APP版本管理列表")
    @PreAuthorize("@ss.hasPermi('gams:version:export')")
    @Log(title = "导出政务APP版本管理列表" , businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(GamsAppVersion gamsAppVersion)
    {
        List<GamsAppVersion> list = gamsAppVersionService.selectGamsAppVersionList(gamsAppVersion);
        ExcelUtil<GamsAppVersion> util = new ExcelUtil<>(GamsAppVersion.class);
        return util.exportExcel(list, "政务APP版本管理数据");
    }

    /**
     * 获取政务APP版本管理详细信息
     */
    @ApiOperation("获取政务APP版本管理详细信息")
    @PreAuthorize("@ss.hasPermi('gams:version:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return AjaxResult.success(gamsAppVersionService.selectGamsAppVersionById(id));
    }

    /**
     * 新增政务APP版本管理
     */
    @ApiOperation("新增政务APP版本管理")
    @PreAuthorize("@ss.hasPermi('gams:version:add')")
    @Log(title = "新增政务APP版本管理" , businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GamsAppVersion gamsAppVersion)
    {
        return toAjax(gamsAppVersionService.insertGamsAppVersion(gamsAppVersion));
    }

    /**
     * 修改政务APP版本管理
     */
    @ApiOperation("修改政务APP版本管理")
    @PreAuthorize("@ss.hasPermi('gams:version:edit')")
    @Log(title = "修改政务APP版本管理" , businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GamsAppVersion gamsAppVersion)
    {
        return toAjax(gamsAppVersionService.updateGamsAppVersion(gamsAppVersion));
    }

    /**
     * 删除政务APP版本管理
     */
    @ApiOperation("删除政务APP版本管理")
    @PreAuthorize("@ss.hasPermi('gams:version:remove')")
    @Log(title = "删除政务APP版本管理" , businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(gamsAppVersionService.deleteGamsAppVersionByIds(ids));
    }
}
